package cn.com.darly.videoandroidpm.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.darly.common.ParentAdapter;

import java.util.List;

import cn.com.darly.videoandroidpm.R;
import cn.com.darly.videoandroidpm.bean.PopInfo;

/**
 * @author Darly/张宇辉/2018/5/4 9:47
 * @version 1.0/cn.com.darly.videoandroidpm.ui.adapter
 */
public class PMPopAdapter extends ParentAdapter<PopInfo> {

    public PMPopAdapter(List<PopInfo> data, int resID, Context context) {
        super(data, resID, context);
    }

    @Override
    public View HockView(int position, View view, ViewGroup parent, int resID, Context context, PopInfo popInfo) {
        ViewHocker hocker = null;
        if (view == null){
            view = LayoutInflater.from(context).inflate(resID,null);
            hocker = new ViewHocker();
            hocker.iv = view.findViewById(R.id.id_pop_pm_icon);
            hocker.tv = view.findViewById(R.id.id_pop_pm_text);
            view.setTag(hocker);
        }else {
            hocker= (ViewHocker) view.getTag();
        }
        hocker.iv.setImageResource(popInfo.getIcon());
        hocker.tv.setText(popInfo.getTitle());
        return view;
    }

    class ViewHocker{
        ImageView iv;
        TextView tv;
    }
}
